package com.iwhalecloud.citybrain.flow.platform.manager.common.client;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import lombok.Data;

/**
 * @author lilh
 * @date 2019-02-18 22:30
 */
@Data
public class HttpCommandDto implements Serializable {
    private static final long serialVersionUID = -1382641022432141236L;

    protected static final String NULL_STRING = "null";

    protected static final String SYSTEM_CODE = "SYSTEM_CODE";

    protected static final String FLOW_PASS_LIST_STR = "FLOW_PASS_LIST";

    protected static final String FLOW_PARAM_LIST_STR = "FLOW_PARAM_LIST";


    private String commandCode;

    private String from;

    private String to = "FLOW";

    private String areaCode;

    private String time;

    private String processInstanceId;

    private String systemCode;

    /**
     * 审批意见
     */
    private String comment;

    private Map<String, Object> infParamMap;

    public Map<String, Object> toMap() {
        Map<String, Object> map = new HashMap<>(10);
        map.put("TIME", this.getTime());
        map.put("FROM", this.getFrom());
        map.put("TO", this.getTo());
        map.put("COMMAND_CODE", this.getCommandCode());
        map.put("AREA_CODE", this.areaCode);
        map.put("PROCESSINSTANCEID", this.processInstanceId);
        map.put("SYSTEM_CODE", this.systemCode);
        return map;
    }

    public void init(Map<String, Object> paramsMap) {
        this.commandCode = String.valueOf(paramsMap.get("COMMAND_CODE"));
        this.from = String.valueOf(paramsMap.get("FROM"));
        this.to = String.valueOf(paramsMap.get("TO"));
        this.areaCode = String.valueOf(paramsMap.get("AREA_CODE"));
        if (NULL_STRING.equals(this.areaCode)) {
            this.areaCode = null;
        }

        this.processInstanceId = String.valueOf(paramsMap.get("PROCESSINSTANCEID"));
        if (paramsMap.get(SYSTEM_CODE) != null) {
            this.systemCode = String.valueOf(paramsMap.get("SYSTEM_CODE"));
        }

    }

    public HttpCommandDto() {
    }

}
